/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring.app.genpostagelabel;

import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import org.apache.poi.hssf.record.formula.functions.Today;
import org.springframework.util.StringUtils;

/**
 *
 * @author ashwani
 */
public class Utils {

    public static String getDate(String format) {
        String todayAsString = null;
        try {
            if (format != null) {
                if (format.equalsIgnoreCase("ddmmyyyy")
                        || format.equalsIgnoreCase("MM/DD/YYYY")
                        || format.equalsIgnoreCase("mmddyyyy")) {
                    todayAsString = new SimpleDateFormat(format).format(new Date());
                } else {
                    todayAsString = new SimpleDateFormat("ddmmyyyy").format(new Date());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();

        }
        return todayAsString ;
    }
    
    public static boolean isEmpty(String str){
    	if(str==null || str.trim().equals(""))
    		return true;
    	return false; 
    }
    public static boolean isEmpty(Object str){
    	if(str==null)
    		return true;
    	return false; 
    }
    public static boolean isEmpty(Collection collection){
    	if(collection!=null && collection.isEmpty())
    		return true;
    	return false;
    	
    }
    
    public static String trim(String str,char c){

    	
    	if(!isEmpty(str))
    		return StringUtils.trimTrailingCharacter(StringUtils.trimLeadingCharacter(str, c),c);
    		return str;
    }
}
